use std::future::Future;
use crate::message::Message;
use crate::workflow::step::WorkflowStep;
use crate::workflow::errors::WorkflowError;
use crate::context::Context;
use crate::actor::ActorRef;

pub struct ActorStepWrapper {
    actor: ActorRef,
}

impl ActorStepWrapper {
    pub fn new(actor: ActorRef) -> Self {
        Self { actor }
    }
}

impl WorkflowStep for ActorStepWrapper {
    fn execute<'a>(&'a self, ctx: &'a Context) -> Box<dyn Future<Output = Result<(), WorkflowError>> + Send + 'a> {
        Box::new(async move {
            // 发送执行消息给 Actor
            ctx.send(&self.actor, Message::Execute).await
                .map_err(|e| WorkflowError::StepFailed(format!("Failed to execute step: {}", e)))
        })
    }
} 